package com.cloudfun.campusshare.service;

import com.cloudfun.campusshare.common.constant.ApplicationStatus;
import com.cloudfun.campusshare.common.constant.ApplicationType;
import com.cloudfun.campusshare.common.model.dto.AuditDTO;
import com.cloudfun.campusshare.common.model.vo.ApplicationSearchVO;
import com.cloudfun.campusshare.common.model.vo.ApplicationVO;
import com.cloudfun.campusshare.common.response.PageResult;
import com.cloudfun.campusshare.entity.ApplicationEntity;
import com.cloudfun.campusshare.entity.AuditEntity;
import org.springframework.data.domain.Pageable;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * Created by Huqin on 2019/12/30
 */
public interface ApplicationService {

    /**
     * 创建申请，提交给管理员审核
     *
     * @param type
     * @param bizId
     * @param contentParams
     */
    ApplicationEntity create(ApplicationType type, String bizId, List<String> contentParams);

    /**
     * 创建申请
     *
     * @param type
     * @param bizId
     * @param contentParams
     * @param auditorId
     */
    ApplicationEntity create(ApplicationType type, String bizId, List<String> contentParams, String auditorId);

    /**
     * 创建申请，提交给管理员审核
     *
     * @param type
     * @param bizId
     * @param contentParams
     * @param attachIds
     */
    void create(ApplicationType type, String bizId, List<String> contentParams, List<String> attachIds);

    /**
     * 创建申请
     *
     * @param type
     * @param bizId
     * @param contentParams
     * @param attachIds
     * @param auditorId
     */
    void create(ApplicationType type, String bizId, List<String> contentParams, List<String> attachIds, String auditorId);

    /**
     * 申请详情
     *
     * @param id
     * @return
     */
    ApplicationVO applicationDetail(String id);

    /**
     * 根据业务类型和id获取有效的申请
     *
     * @param type
     * @param bizId
     * @return
     */
    ApplicationVO getValidApplicationDetailByBizTypeId(ApplicationType type, String bizId);

    /**
     * 审核
     *
     * @param auditDTO
     */
    void audit(AuditDTO auditDTO);

    /**
     * 删除
     *
     * @param ids
     */
    Map<String, String> updateEnabled(List<String> ids);

    /**
     * 删除
     *
     * @param searchVO
     */
    Map<String, String> updateEnabled(ApplicationSearchVO searchVO);

    /**
     * 删除
     */
    Map<String, String> updateEnabled();

    /**
     * 分页搜索
     *
     * @param searchVO
     * @param pageable
     * @return
     */
    PageResult<ApplicationVO> search(ApplicationSearchVO searchVO, Pageable pageable);

    /**
     * 根据bizId删除
     *
     * @param bizId
     */
    void deleteByBizId(String bizId);

    /**
     * 根据业务Id和类型查找最后一个申请
     *
     * @param bizId
     * @param type
     * @return
     */
    ApplicationEntity getLatestValid(String bizId, ApplicationType type);

    /**
     * 根据业务Id和类型查找最后一个审核
     *
     * @param bizId
     * @param type
     * @return
     */
    AuditEntity getLatestAuditByBizIdAndType(String bizId, ApplicationType type);

    /**
     * 统计
     *
     * @param types
     * @param status
     * @return
     */
    Long countByTypeNotInAndStatusAndEnabled(Collection<ApplicationType> types, ApplicationStatus status);
}
